/*
- @Author: Wangjun
- @Date: 2023-08-15 19:03:33

  - @LastEditTime: 2023-10-16 09:27:15

  - @LastEditors: Wangjun

- @Description:
  - @FilePath: \nodex\value.go

- hnxr
*/
package nodex

/**
 * @description: 是否是参数
 * @param {string} name
 * @return {*}
 */
func IsParam(name string) bool {
	switch name {
	case "Boolean", "Double", "ArrayDouble", "ArrayBool":
		return true
	}
	return false
}

/**
 * @description: 获取参数的默认值
 * @param {string} name
 * @return {*}
 */
func GetParamDefaultValue(name string) string {
	switch name {
	case "Boolean":
		return "false"
	case "Double":
		return "0"
	case "ArrayDouble", "ArrayBool":
		return "[]"
	}
	return ""
}

var (
	_ = Valuer(new(Boolean))
	_ = Valuer(new(Double))
	_ = Valuer(new(ArrayBool))   //开关量数组
	_ = Valuer(new(ArrayDouble)) //模拟量数组
)

type Outter interface {
	Equal(Outter) bool //是否相等
	New() Outter       //新建一个值
	Set(Outter) error  //设置值
}

type Valuer interface {
	CopyAttr(v Valuer)             //复制参数
	SetID(id string)               //设置值的id
	GetID() string                 //获取值的id
	GetType() string               //获取值的类型
	SetEdge(edge string)           //设置连线的id
	GetPrevPort() string           //获取上一步关联的id
	SetPrevPort(string)            //设置上一步参数关联的id
	SetValue(any) (err error)      //设定参数的值
	Link(value Valuer) (err error) //B 关联A的值
}
